-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix IDE crash on @AfterClass #3027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix IDE crash on @AfterClass #3027
Conversation
This is a workarround for a infinite fold done on Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,annotation)),Target)]),<init>),List(NamedArg(value,JavaSeqLiteral(List(Literal(Constant(val ANNOTATION_TYPE))), TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,annotation)),ElementType)]))))
Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,annotation)),Target)]),<init>)
New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,annotation)),Target)])
Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,annotation)),Target)]),<init>),List(NamedArg(value,JavaSeqLiteral(List(Literal(Constant(val ANNOTATION_TYPE))), TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,annotation)),ElementType)]))))
...
|
27032b5
to
80c57f2
Compare
@odersky, completely reimplemented the fix. I found the source of the issue and fixed it there. |
80c57f2
to
dda2256
Compare
Resigned to @smarter as the code is it involves the IDE |
Maybe add a comment explaining why this is necessary. |
if (!t.symbol.isCompleted) t.symbol.info = UnspecifiedErrorType | ||
t.symbol.annotations.foreach(annot => cleanup(annot.tree)) | ||
private def cleanup(tree: tpd.Tree)(implicit ctx: Context): Unit = { | ||
val cleanedTree = mutable.Set.empty[tpd.Tree] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would call this variable seen
, this is the name we commonly use in the compiler for cycle detection.
The TreeAccumulator was stuck in an infinite loop over the synthetic constructor of java annotations. This could be reproduced by opening the CompilationTests.scala in the IDE.
fa2af08
to
c552416
Compare
cleanedTree += tree | ||
tree.foreachSubTree { t => | ||
if (t.hasType) { | ||
if (t.symbol.exists) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (t.hasType && t.symbol.exists)
?
@allanrenucci, could you review the last commit and merge if ok. |
As suggested by @smarter, I would add a comment explaining why this is necessary. Otherwise LGTM |
The TreeAccumulater was stuck in an infinite loop over the
synthetic constructor of java annotations. This could be reproduced
by opening the CompilationTests.scala in the IDE.